<template>
  <div class="data-amount-item-wrap">
    <div class="large-style data-amount-item">
      <img v-if="isShowFlag" :src="itemIcon" class="item-icon" alt="">
      <div class="info-content">
        <div class="amount">
          <span>{{ dataDetail | bigNumFloorFilter }}</span>
        </div>
        <div class="label">
          <span class="">{{ label }}</span>
          <el-tooltip v-if="tip" class="item" effect="dark" placement="top">
            <div slot="content" style="max-width: 170px; text-align: center">
              <!-- 下单日期为本月之前的（待核销或部分核销）订单，封账发起时间前，待核销总额 -->
              {{ tip }}
            </div>
            <tipIcon is-diy class="icon-info" />
          </el-tooltip>
        </div>
      </div>
    </div>
    <div :class="{ 'no-flag-item': !isShowFlag }" class="small-style data-amount-item">
      <div class="info-content">
        <div class="amount">
          <div :style="{'background': flagColor}" class="flag-color" />
          <span>{{ dataDetail | bigNumFloorFilter }}</span>
        </div>
        <div class="label">
          <div class="label-text">{{ label }}</div>
          <el-tooltip v-if="tip" class="item" effect="dark" placement="top">
            <div slot="content" style="max-width: 170px; text-align: center">
              {{ tip }}
            </div>
            <tipIcon is-diy class="icon-info" />
          </el-tooltip>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import allAmount from '@/assets/allAmount.png';
import { bigNumFloorFilter } from '@/filters/number';
export default {
  name: 'DataAmountItem',
  filters: {
    bigNumFloorFilter
  },
  props: {
    itemIcon: {
      type: String,
      default: allAmount
    },
    writeOffData: {
      type: Object,
      default: () => null
    },
    propName: {
      type: String,
      default: ''
    },
    label: {
      type: String,
      default: ''
    },
    flagColor: {
      type: String,
      default: '#406EFF'
    },
    isShowFlag: {
      type: Boolean,
      default: true
    },
    tip: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      allAmount
    };
  },
  computed: {
    dataDetail() {
      if (this.writeOffData && this.propName in this.writeOffData) {
        if (this.writeOffData[this.propName] !== 0) {
          return this.writeOffData[this.propName] / 100;
        } else {
          return this.writeOffData[this.propName];
        }
      }
      return '--';
    }
  }
};
</script>
<style lang="scss" scoped>
.data-amount-item-wrap {
  flex: 1;
  border: 1px solid #EBEEFD;
  margin: 0 0 -1px -1px;
}
.data-amount-item {
  position: relative;
  height: 118px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  .flag-color {
    width: 8px;
    height: 8px;
    margin: 0px 8px;
    border-radius: 50%;
  }
  .item-icon {
    height: 40px;
    width: 40px;
    margin-right: 12px;
  }
  .info-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    .amount {
      display: flex;
      align-items: center;
      margin-bottom: 12px;
      font-size: 24px;
      color: #333333;
      font-weight: bold;
      line-height: 1;
    }
    .label {
      display: flex;
      flex: 1;
      align-items: center;
      color: #A9AFB6;
      font-size: 13px;
      line-height: 1;
      .icon-info {
        width: 14px;
        height: 14px;
        font-size: 14px;
        color: #406EFF;
        margin-left: 4px;
      }
    }
  }
}
.small-style {
  flex-direction: column;
  align-items: self-end;
  padding: 0 0px;
  display: none;
  .info-content {
    justify-content: center;
    .label {
      flex: 0;
      margin-left: 24px;
      .label-text {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }
      font-size: 12px;
    }
  }
  &.no-flag-item {
    // align-items: center;
    .info-content {
      justify-content: center;
      // align-items: center;
    }
  }
}
@media screen and (max-width : 1620px) {
  .small-style {
    display: flex;
  }
  .large-style {
    display: none;
  }
}
</style>
